﻿using Abp.ObjectMapping;
using Abp.Runtime.Caching;
using AVIS.OutBound.RentalPolicys.Dto;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AVIS.OutBound.RentalPolicys
{
    public class RentalPolicyAppService : OutBoundAppServiceBase, IRentalPolicyAppService
    {
        private readonly IRentalPolicyManager _rentalPolicyManager;
        private readonly IObjectMapper _objectMapper;

        /// <summary>
        /// 租车政策
        /// </summary>
        /// <param name="objectMapper"></param>
        /// <param name="rentalPolicyManager"></param>
        public RentalPolicyAppService(IObjectMapper objectMapper,
            IRentalPolicyManager rentalPolicyManager)
        {
            _rentalPolicyManager = rentalPolicyManager;
            _objectMapper = objectMapper;
        }

        /// <summary>
        /// 根据regionCode获取租车须知
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public RentalPolicyOutput GetRentalPolicyByRegionCode(RentalPolicyInput input)
        {
            var rpoCacheItem = _rentalPolicyManager.GetRentalPolicyByRegionCode(input.regionCode);
            return _objectMapper.Map<RentalPolicyOutput>(rpoCacheItem);
        }
    }
}
